package com.zkingsofter.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.zkingsoft.model.PaginationVO;
import com.zkingsoft.model.Student;
import com.zkingsoft.services.StudentService;

import junit.framework.Assert;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:applicationContext-test.xml" })
public class test1 {
	@Resource

	StudentService StudentService;

	@Test
	public void add() {
		for (int i = 0; i < 10; i++) {
			Student user = new Student();
			user.setName("姜友瑶");
			user.setPassword("123");
			StudentService.add(user);
			System.out.println(user.getId());
		}
	}

	@Test
	public void update() {
		Student user = new Student();
		user.setId(100);
		user.setName("姜友瑶2");
		StudentService.modify(user);
	}

	@Test
	public void findByid() {

		Assert.assertNotNull(StudentService.findById(100));
	}

	@Test
	public void findInPage() {
		PaginationVO pageVo = new PaginationVO();

		Student user = new Student();
		user.setCoachId(1);
		int i = StudentService.findTotal(user);
		List<Student> list = StudentService.findInPage(user, pageVo);
		System.out.println(list.size());
		System.out.println(i);

	}

	@Test
	public void delete() {
		/*
		 * CtUser user=new CtUser(); user.setName("姜友瑶");
		 * user.setPassword("123");
		 */
		StudentService.removeById(1);
	}

	@Test
	public void deleteList() {
		/*
		 * CtUser user=new CtUser(); user.setName("姜友瑶");
		 * user.setPassword("123");
		 */
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 2; i < 100; i++) {
			list.add(i);
		}
		StudentService.remove(list);
	}

}
